<?php

class Core_Backend_Component_Permission_View_Account_Index extends Core_Backend_Share_View_Grid {

    protected function buildToolbar($toolbar) {
    	parent::buildToolbar($toolbar);
    	$group = $toolbar->createGroup();
        $group->addLink($this->getUrl(NULL, 'create'), $this->__('share.button.create'));
        $group->addButton($this->__('share.button.batch_edit'))
        	  ->bindEvent('click', "submitGridChecked('" . $this->getGrid()->getId() . "', '" . $this->getUrl(NULL, 'batchedit') . "')");
    }

    protected function buildGrid($grid) {
        $search = $this->getData('search');
        $grid->setId('operationGrid')
                ->setPrimaryKey('id')
                ->addLabelColumn($this->__('share.label.userName'), 'user_name', '{user_name}')
                ->setWidth(200)
                ->getGrid()
                ->addLabelColumn($this->__('share.label.status'), 'status', '{{lang "status.enable.{status}"}}', Kd_Localize_Helper::getLanguageItems('share.status'))
                ->setWidth(200)
                ->getGrid()
                ->addLabelColumn($this->__('permission.label.full_name'), 'full_name', '{full_name}')
                ->setWidth(200)
                ->getGrid()
                ->addLabelColumn($this->__('permission.label.email'), 'email', '{email}')
                ->setWidth(300)
                ->getGrid()
                ->addLinkColumn('#', 'edit', $this->getUrl(array('id' => '{id}'), 'edit'), $this->__('share.button.edit'))
                ->setWidth(40)
                ->setAlign('center')
                ->getGrid()
                ->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }

    protected function buildPagination($pagination) {
        $url = $this->getPaginationUrl(array('name' => $this->getRequest()->getQuery('name'), 'domain' => $this->getRequest()->getQuery('domain')));
        $pagination->setUrlFormat($url)
                ->setRecordCount($this->getRecords());
        parent::buildPagination($pagination);
    }

}